const serviceSql=require('../service/service')

class codekeyController{
    async codeKey(ctx,next){
        let result=await serviceSql.codeAll()
        let data=[]
        result.forEach(item=>{
            let img = 'https://quickchart.io/qr?text='+item.code
            const {code,id}=item
            data.push({img,code,id})
        })
        ctx.mesg="获取成功"
        ctx.body=data
        await next()
    }
    async stadium(ctx,next){
        let result=await serviceSql.stadium()
        let data=[]
        result.forEach(item=>{
            let img='https://quickchart.io/qr?text='+item.id
            let id=item.id
            data.push({img,id})
        })
        ctx.mesg="获取成功"
        ctx.body=data
        await next()
    }
}

module.exports=new codekeyController()